package Lesson19.Notepad;

public class Page 
{
	
	// smth from Eclipse
	
	private int title;
	private String text = "";
		Page (int title)
	{
		if (title == 0)
			{
				System.out.println("Wrong title format!");
				this.title = 0;
			}
		else
			this.title = title;
	}
	
	protected int getHeader()
	{
		return this.title;
	}
	protected String getText()
	{
		return this.text;
	}
	
	void addText(final String text)
	{
		if (text != null)
		{
			if (this.text.equals(""))
				this.text += text;
			else
				this.text += "\n" + text;
		}
		else
			System.out.println("Wrong text format!");
	}
	
	void deleteText()
	{
		this.text = "";
	}
	
	protected void reviewPage ()
	{
		System.out.println("========== Page " + this.title + " ==========");
		System.out.println(this.text);
	}
	
	@Override
	public boolean equals(Object obj) 
	{
		if(obj instanceof Page)
		{
			return ((Page) obj).title == this.title;
		}
		else
			return false;
	}
}
// new comment
